package com.networkmanagerj.service.flex;

import com.networkmanagerj.model.Usuario;

import flex.messaging.FlexContext;
import flex.messaging.FlexSession;

public abstract class JFlexService
{
	protected static String	SESSION_PU_NAME	= "SESSION_ID";
	protected static String	SESSION_USER	= "SESSION_USER";
	protected FlexSession	session;

	protected boolean validarSessao()
	{
		this.session = FlexContext.getFlexSession();
		if (!this.session.isValid())
			return false;
		if (this.session.getAttribute(SESSION_USER) == null)
			return false;
		if (this.session.getAttribute(SESSION_PU_NAME) == null)
			return false;
		return true;
	}
	
	protected String getSessionPUName()
	{
		return (String) this.session.getAttribute(SESSION_PU_NAME);
	}
	
	protected Usuario getSessionUser()
	{
		return (Usuario) this.session.getAttribute(SESSION_USER);
	}

	public JFlexService()
	{
		this.session = FlexContext.getFlexSession();
	}

}
